package com.three.iot.jdbc.dao;

import com.three.iot.commons.dto.SysDictCondDto;
import com.three.iot.jdbc.model.SysDictInfo;
import com.three.iot.jdbc.mapper.SysDictInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author luiz
 * @Title: DictDao
 * @ProjectName iot
 * @Description: TODO
 * @date 2019-04-04 14:05
 */
@Service
public class DictDao {
    @Resource
    SysDictInfoMapper sysDictInfoMapper;

    public List<SysDictInfo> findAll() {
        return sysDictInfoMapper.selectAll();
    }

    public void insert(SysDictInfo SysDictInfo) {
        SysDictInfo.setCreateTime(new Date());
        sysDictInfoMapper.insertSelective(SysDictInfo);
    }

    public void update(SysDictInfo SysDictInfo) {
        SysDictInfo.setModiTime(new Date());
        sysDictInfoMapper.updateByPrimaryKeySelective(SysDictInfo);
    }

    public List<SysDictInfo> findByPDict(String pDictCode) {
        return sysDictInfoMapper.selectBypDictNo(pDictCode);
    }

    public List<SysDictInfo> findList(SysDictCondDto sysDictCondDto) {
        return sysDictInfoMapper.selectList(sysDictCondDto);
    }

    public SysDictInfo findByUniq(String dictType, String dictCode) {
        return sysDictInfoMapper.findByUniq(dictType, dictCode);
    }
}
